package com.redteam.data.beans;

import com.redteam.interfaces.Customer;
import java.io.Serializable;
import java.sql.Date;

/**
 * A java bean for Students
 * @author Anthony Ferrari
 */
public final class Student extends Pilot implements Customer, Serializable {

    private Instructor preferredInstructor;
    private HouseAccount account;
    private static final long serialVersionUID = 1L;


    /**
     * The full constructor
     * @param id The ID of the student.
     * @param firstName The Student's first name.
     * @param middleName The Student's middle name.
     * @param lastName The Student's last name.
     * @param street The Student's Street name.
     * @param city The Student's city.
     * @param state The Student's state.
     * @param zipCode The Student's zipcode.
     * @param email The Student's email address.
     * @param fBOId The FBO ID the Student is registered at.
     * @param birthdate The Student's birth date.
     * @param homePhone The Student's home phone number.
     * @param cellPhone The Student's cell phone number.
     * @param workPhone The Student's work phone number.
     * @param gender The Student's gender.
     * @param flightHours The Student's total flight hours.
     * @param type The Student's discriminator.
     * @param username The Student's user name.
     * @param password The Student's password.
     */
    public Student(long id, String firstName, String middleName, String lastName, String street, String city, String state, String zipCode, String email, long fBOId, Date birthdate, String homePhone, String cellPhone, String workPhone, String gender, int flightHours, String type, String username, String password) {
        super(id, firstName, middleName, lastName, street, city, state, zipCode, email, fBOId, birthdate, homePhone, cellPhone, workPhone, gender, flightHours, type, username, password);
        this.setPreferredInstructor(new Instructor());
    }

    /**
     * Default constructor
     */
    public Student() {
        super();
        this.setPreferredInstructor(new Instructor());
    }

    /**
     * Returns the preferred instructor
     * @return preferredInstructor
     */
    public Instructor getPreferredInstructor() {
        return preferredInstructor;
    }

    /**
     * Sets the preferred instructor
     * @param preferedInstructor
     */
    public void setPreferredInstructor(Instructor preferedInstructor) {
        this.preferredInstructor = preferedInstructor;
    }

    /**
     * @inheritDoc
     */
    @Override
    public HouseAccount getHouseAccount() {

        return account;
    }

    /**
     * @inheritDoc
     */
    @Override
    public void setHouseAccount(HouseAccount account) {
        this.account = account;
    }

    /**
     * @inheritDoc
     */
    @Override
    public double makePayment(Payment payment) {
        double amount = account.getBalance() - payment.getPaymentAmount();
        account.setBalance(amount);

        return amount;
    }

    /**
     * @inheritDoc
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Student other = (Student) obj;
        if (this.preferredInstructor != other.preferredInstructor && (this.preferredInstructor == null || !this.preferredInstructor.equals(other.preferredInstructor))) {
            return false;
        }
        if (this.account != other.account && (this.account == null || !this.account.equals(other.account))) {
            return false;
        }
        return true;
    }

    /**
     * @inheritDoc
     */
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.preferredInstructor != null ? this.preferredInstructor.hashCode() : 0);
        hash = 79 * hash + (this.account != null ? this.account.hashCode() : 0);
        return hash;
    }
}
